package cn.yuanqiao.archive.management.domain;

import cn.yuanqiao.common.annotation.Excel;
import cn.yuanqiao.common.annotation.IdAnnotation;
import cn.yuanqiao.common.exception.ServiceException;
import cn.yuanqiao.common.utils.StringUtils;
import cn.yuanqiao.common.core.domain.BaseEntity;
import cn.yuanqiao.common.utils.SecurityUtils;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import java.util.Date;

/**
 * 载体对象 YQZT
 * 
 * @author sy
 * @date 2023-07-10
 */
public class YqZt extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    private final String BIGTABLENAME = "_YQZT";

    public YqZt() {
        String userCode = SecurityUtils.getTenantCode();
        if(StringUtils.isEmpty(userCode)){
            throw new ServiceException("TenantCode is null");
//            this.tableName = "YQZT";
        }else {
            this.tableName = userCode.toUpperCase()+BIGTABLENAME;
//            this.tableName = "YQZT";
        }
    }

    private String tableName;

    public String getTableName() {
        return tableName;
    }

    public void setTableName(String tableName) {
        this.tableName = tableName;
    }

    /** 载体ID */
    @IdAnnotation
    private Long ztId;

    /** 载体类型ID */
    @Excel(name = "载体类型ID")
    private Long ztlxId;

    /** 载体类型名称 */
    @Excel(name = "载体类型名称")
    private String ztlxName;

    /** 载体编号（唯一） */
    @Excel(name = "载体编号", readConverterExp = "唯一")
    private String code;

    /** 挂载路径 */
    @Excel(name = "挂载路径")
    private String savePath;

    /** 载体保存位置 */
    @Excel(name = "载体保存位置")
    private String offlineSavePath;

    /** 大小（默认单位是MB） */
    @Excel(name = "大小", readConverterExp = "默=认单位是MB")
    private String size;

    /** 是否已用 */
    @Excel(name = "是否已用")
    private Integer isUse;

    /** 保存策略 */
    @Excel(name = "保存策略")
    private String savePolicy;

    /** 定检周期 */
    @Excel(name = "定检周期")
    private String cycle;

    /** 创建人 */
    @Excel(name = "创建人")
    private Long creatorId;

    /** 创建时间 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date createTime;

    /** 最后修改人 */
    @Excel(name = "最后修改人")
    private Long lastupdater;

    /** 最后修改时间 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "最后修改时间", width = 30, dateFormat = "yyyy-MM-dd")
    private Date lastupdateTime;

    /** 是否删除 */
    @Excel(name = "是否删除")
    private Integer isDel;

    /** 剩余容量 */
    private String surplus;

    /** 格式转换后的剩余容量 */
    private String surplusConvert;

    private String errorMsg;

    public void setZtId(Long ztId) 
    {
        this.ztId = ztId;
    }

    public Long getZtId() 
    {
        return ztId;
    }
    public void setZtlxId(Long ztlxId) 
    {
        this.ztlxId = ztlxId;
    }

    public String getZtlxName() {
        return ztlxName;
    }

    public void setZtlxName(String ztlxName) {
        this.ztlxName = ztlxName;
    }

    public Long getZtlxId()
    {
        return ztlxId;
    }
    public void setCode(String code) 
    {
        this.code = code;
    }

    public String getCode() 
    {
        return code;
    }
    public void setSavePath(String savePath) 
    {
        this.savePath = savePath;
    }

    public String getSavePath() 
    {
        return savePath;
    }
    public void setOfflineSavePath(String offlineSavePath) 
    {
        this.offlineSavePath = offlineSavePath;
    }

    public String getOfflineSavePath() 
    {
        return offlineSavePath;
    }
    public void setSize(String size) 
    {
        this.size = size;
    }

    public String getSize() 
    {
        return size;
    }
    public void setIsUse(Integer isUse) 
    {
        this.isUse = isUse;
    }

    public Integer getIsUse() 
    {
        return isUse;
    }
    public void setSavePolicy(String savePolicy) 
    {
        this.savePolicy = savePolicy;
    }

    public String getSavePolicy() 
    {
        return savePolicy;
    }
    public void setCycle(String cycle) 
    {
        this.cycle = cycle;
    }

    public String getCycle() 
    {
        return cycle;
    }
    public void setCreatorId(Long creatorId)
    {
        this.creatorId = creatorId;
    }

    public Long getCreatorId()
    {
        return creatorId;
    }
    public void setLastupdater(Long lastupdater)
    {
        this.lastupdater = lastupdater;
    }

    @Override
    public Date getCreateTime() {
        return createTime;
    }

    @Override
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Long getLastupdater()
    {
        return lastupdater;
    }
    public void setLastupdateTime(Date lastupdateTime) 
    {
        this.lastupdateTime = lastupdateTime;
    }

    public Date getLastupdateTime() 
    {
        return lastupdateTime;
    }
    public void setIsDel(Integer isDel) 
    {
        this.isDel = isDel;
    }

    public Integer getIsDel() 
    {
        return isDel;
    }

    public String getSurplus() {
        return surplus;
    }

    public void setSurplus(String surplus) {
        this.surplus = surplus;
    }

    public String getSurplusConvert() {
        return surplusConvert;
    }

    public void setSurplusConvert(String surplusConvert) {
        this.surplusConvert = surplusConvert;
    }

    public String getErrorMsg() {
        return errorMsg;
    }

    public void setErrorMsg(String errorMsg) {
        this.errorMsg = errorMsg;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
            .append("ztId", getZtId())
            .append("ztlxId", getZtlxId())
            .append("ztlxName", getZtlxName())
            .append("code", getCode())
            .append("savePath", getSavePath())
            .append("offlineSavePath", getOfflineSavePath())
            .append("size", getSize())
            .append("isUse", getIsUse())
            .append("savePolicy", getSavePolicy())
            .append("cycle", getCycle())
            .append("creatorId", getCreatorId())
            .append("createTime", getCreateTime())
            .append("lastupdater", getLastupdater())
            .append("lastupdateTime", getLastupdateTime())
            .append("isDel", getIsDel())
            .toString();
    }
}
